package com.sa.web.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import com.sa.web.bean.AdminBean;
import com.sa.web.bean.StuInfoBean;
import com.sa.web.dao.service.AdminInfoDao;

public class AdminInfoDaoImpl implements AdminInfoDao{
	
	private SqlMapClientTemplate sqlMapClientTemplate;

	/**
	 * 获得管理员信息列表
	 */
	@Override
	public List<AdminBean> getAdminInfoList(String adminName,int start,int size) {
		Map<String,Object> map = new HashMap<String,Object> ();
		map.put("adminName", adminName);
		map.put("start", start);
		map.put("size", size);
		return (List<AdminBean>)sqlMapClientTemplate.queryForList("getAdminInfoList",map);
	}
	
	/**
	 * 删除管理员信息列表
	 */
	public boolean deleteAdminInfo(String adminId){
		return sqlMapClientTemplate.delete("deleteAdminInfo",adminId)>0;
	}
	/**
	 * 获得管理员信息总数
	 */
	@Override
	public Integer getAdminInfoCount(String adminName) {
		Map<String,Object> map = new HashMap<String,Object> ();
		map.put("adminName", adminName);
		return (Integer)sqlMapClientTemplate.queryForObject("getAdminInfoCount",map);
	}
	
	/**
	 * 获得单条管理员信息
	 */
	@Override
	public AdminBean getAdminInfo(String adminId) {
		return (AdminBean)sqlMapClientTemplate.queryForObject("getAdminInfo", adminId);
	}
	
	@Override
	public AdminBean adminLogin(String adminName) {
		return (AdminBean)sqlMapClientTemplate.queryForObject("adminLogin", adminName);
	}
	
	/**
	 * 增加管理员信息
	 */
	@Override
	public boolean addAdminInfo(AdminBean adminInfo) {
		return (Integer)sqlMapClientTemplate.insert("addAdminInfo", adminInfo)>1;
	}
	/**
	 * 修改管理员信息
	 */
	@Override
	public boolean updateAdminInfo(AdminBean adminInfo) {
		return sqlMapClientTemplate.update("updateAdminInfo", adminInfo)>0;
	}

	public SqlMapClientTemplate getSqlMapClientTemplate() {
		return sqlMapClientTemplate;
	}

	public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) {
		this.sqlMapClientTemplate = sqlMapClientTemplate;
	}

}
